package com.qezhhnjy.demo.schedule.simple;

import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author zhaoyangfu - 2021/1/4 13:44
 * 最简易的定时任务，不需要任何配置,可以通过 spring.task.schedule 进行配置，默认线程池为1
 */
@Component
@Slf4j
@EnableScheduling
public class SimpleSchedule {

    @Scheduled(fixedRate = 5000)
    public void first() {
        log.info("simple schedule first");
        ThreadUtil.sleep(5000);
    }

    @Scheduled(fixedRate = 5000)
    public void second() {
        log.info("simple schedule second");
        ThreadUtil.sleep(5000);
    }
}
